



//
//  MainDetailView.m
//  1243
//
//  Created by apple on 16/7/6.
//  Copyright © 2016年 1243. All rights reserved.
//

#import "MainDetailView.h"
#import "MainDetailTViewCell.h"
@interface MainDetailView ()<UITableViewDelegate,UITableViewDataSource>

@end
@implementation MainDetailView
{
    UITableView     *mainTV;
    
}

- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        
        mainTV = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height) style:UITableViewStyleGrouped];
        
        mainTV.delegate = self;
        mainTV.dataSource =self;
        mainTV.showsVerticalScrollIndicator = NO;
        mainTV.backgroundColor = [UIColor lightGrayColor];
        [mainTV registerClass:[MainDetailTViewCell class] forCellReuseIdentifier:@"CELL"];
        [self addSubview:mainTV];
        
        
    }
    return self;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return WIDTH/3 + 130;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.01;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.01;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MainDetailTViewCell *cell = [mainTV dequeueReusableCellWithIdentifier:@"CELL" forIndexPath:indexPath];
    cell.titleLB.text = @"一元夺宝";
    cell.aititudeLB.text = @"等待揭晓";
    cell.nameLB.mContent = @"挨打了客户来看离开李克强就我离开的看起我哪里的可能完全离开你立刻前往";
    cell.qiLB.text = @"第XXX期";
    cell.moneyLB.text = @"实付款:  ¥100.00";
    cell.moneyLB.attributedText=[self returnText:cell.moneyLB.text];
    
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.jumpToMainBlock = ^void(){
        if (self.jumpToMainBlock) {
            self.jumpToMainBlock();
        }
        
    };
    
    return cell;
}

- (NSMutableAttributedString *)returnText:(NSString *)str {
    NSMutableAttributedString *hintString=[[NSMutableAttributedString alloc]initWithString:str];
    //获取要调整颜色的文字位置,调整颜色
    NSRange range1=[[hintString string]rangeOfString:@"实付款:"];
    [hintString addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:range1];
    
    return hintString;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    if (self.dingdanBlock) {
        self.dingdanBlock();
    }
}


@end
